package com.google.gwt.sample.json.client;

import asquare.gwt.tk.client.ui.ModalDialog;
import asquare.gwt.tk.client.ui.RowPanel;

import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Composite;

abstract class EntryPanel extends Composite{
	public EntryPanel(){
		panel.setWidth("700px");
		panel.setStyleName("gwt-WorkshopLabel2");		
		initWidget(panel);
	}
	class CloseListener implements ClickListener
	{
		private final ModalDialog m_dialog;			
		public CloseListener(ModalDialog dialog){m_dialog = dialog;}
		public void onClick(Widget sender){m_dialog.hide();}
	}		
	class CloseButton extends Button
	{
		public CloseButton(ModalDialog dialog)
		{
			super("Close");
			addClickListener(new CloseListener(dialog));
		}
	}
	class PhotoAlbumClickListener implements ClickListener{
		public String photoURL;
		public PhotoAlbumClickListener(String photoURL){
			this.photoURL = photoURL;
		}
		public void onClick(Widget sender)
		{
			final ModalDialog dialog = new ModalDialog();
			final RowPanel rp = new RowPanel();
			dialog.setCaption("Caption area", false);
			rp.add(new Image(photoURL));
			rp.add(new CloseButton(dialog));
			dialog.add(rp);
			dialog.show();
		}
	}
	public abstract void updateEntry(JSONValue json);
	public abstract String searchText();
	protected VerticalPanel panel = new VerticalPanel();
	protected Image photo  = new Image("home.gif");	
	protected Label titleLabel = new Label("Workshop Title");
	protected Label richTextArea = new Label("FOO");

}
